home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / JFrame.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  5.2 KB  |  202 lines

  1. package javax.swing;
  2.  
  3. import java.awt.AWTEvent;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.Frame;
  7. import java.awt.Graphics;
  8. import java.awt.LayoutManager;
  9. import java.awt.event.InputEvent;
  10. import java.awt.event.KeyEvent;
  11. import java.awt.event.WindowEvent;
  12. import javax.accessibility.Accessible;
  13. import javax.accessibility.AccessibleContext;
  14.  
  15. public class JFrame extends Frame implements WindowConstants, Accessible, RootPaneContainer {
  16.    private int defaultCloseOperation = 1;
  17.    protected JRootPane rootPane;
  18.    protected boolean rootPaneCheckingEnabled = false;
  19.    protected AccessibleContext accessibleContext = null;
  20.  
  21.    public JFrame() {
  22.       this.frameInit();
  23.    }
  24.  
  25.    public JFrame(String var1) {
  26.       super(var1);
  27.       this.frameInit();
  28.    }
  29.  
  30.    protected void addImpl(Component var1, Object var2, int var3) {
  31.       if (this.isRootPaneCheckingEnabled()) {
  32.          throw this.createRootPaneException("add");
  33.       } else {
  34.          super.addImpl(var1, var2, var3);
  35.       }
  36.    }
  37.  
  38.    protected JRootPane createRootPane() {
  39.       return new JRootPane();
  40.    }
  41.  
  42.    private Error createRootPaneException(String var1) {
  43.       String var2 = this.getClass().getName();
  44.       return new Error("Do not use " + var2 + "." + var1 + "() use " + var2 + ".getContentPane()." + var1 + "() instead");
  45.    }
  46.  
  47.    protected void frameInit() {
  48.       ((Component)this).enableEvents(72L);
  49.       this.setRootPane(this.createRootPane());
  50.       ((Component)this).setBackground(UIManager.getColor("control"));
  51.       this.setRootPaneCheckingEnabled(true);
  52.    }
  53.  
  54.    public AccessibleContext getAccessibleContext() {
  55.       if (this.accessibleContext == null) {
  56.          this.accessibleContext = new AccessibleJFrame(this);
  57.       }
  58.  
  59.       return this.accessibleContext;
  60.    }
  61.  
  62.    public Container getContentPane() {
  63.       return this.getRootPane().getContentPane();
  64.    }
  65.  
  66.    public int getDefaultCloseOperation() {
  67.       return this.defaultCloseOperation;
  68.    }
  69.  
  70.    public Component getGlassPane() {
  71.       return this.getRootPane().getGlassPane();
  72.    }
  73.  
  74.    public JMenuBar getJMenuBar() {
  75.       return this.getRootPane().getMenuBar();
  76.    }
  77.  
  78.    public JLayeredPane getLayeredPane() {
  79.       return this.getRootPane().getLayeredPane();
  80.    }
  81.  
  82.    public JRootPane getRootPane() {
  83.       return this.rootPane;
  84.    }
  85.  
  86.    protected boolean isRootPaneCheckingEnabled() {
  87.       return this.rootPaneCheckingEnabled;
  88.    }
  89.  
  90.    protected String paramString() {
  91.       String var1;
  92.       if (this.defaultCloseOperation == 1) {
  93.          var1 = "HIDE_ON_CLOSE";
  94.       } else if (this.defaultCloseOperation == 2) {
  95.          var1 = "DISPOSE_ON_CLOSE";
  96.       } else if (this.defaultCloseOperation == 0) {
  97.          var1 = "DO_NOTHING_ON_CLOSE";
  98.       } else if (this.defaultCloseOperation == 3) {
  99.          var1 = "EXIT_ON_CLOSE";
  100.       } else {
  101.          var1 = "";
  102.       }
  103.  
  104.       String var2 = this.rootPane != null ? this.rootPane.toString() : "";
  105.       String var3 = this.rootPaneCheckingEnabled ? "true" : "false";
  106.       return super.paramString() + ",defaultCloseOperation=" + var1 + ",rootPane=" + var2 + ",rootPaneCheckingEnabled=" + var3;
  107.    }
  108.  
  109.    protected void processKeyEvent(KeyEvent var1) {
  110.       super.processKeyEvent(var1);
  111.       if (!((InputEvent)var1).isConsumed()) {
  112.          JComponent.processKeyBindingsForAllComponents(var1, this, ((AWTEvent)var1).getID() == 401);
  113.       }
  114.  
  115.    }
  116.  
  117.    protected void processWindowEvent(WindowEvent var1) {
  118.       super.processWindowEvent(var1);
  119.       if (((AWTEvent)var1).getID() == 201) {
  120.          switch (this.defaultCloseOperation) {
  121.             case 0:
  122.             default:
  123.                break;
  124.             case 1:
  125.                ((Component)this).setVisible(false);
  126.                break;
  127.             case 2:
  128.                ((Component)this).setVisible(false);
  129.                ((Frame)this).dispose();
  130.                break;
  131.             case 3:
  132.                System.exit(0);
  133.          }
  134.       }
  135.  
  136.    }
  137.  
  138.    public void remove(Component var1) {
  139.       if (var1 == this.rootPane) {
  140.          super.remove(var1);
  141.       } else {
  142.          this.getContentPane().remove(var1);
  143.       }
  144.  
  145.    }
  146.  
  147.    public void setContentPane(Container var1) {
  148.       this.getRootPane().setContentPane(var1);
  149.    }
  150.  
  151.    public void setDefaultCloseOperation(int var1) {
  152.       this.defaultCloseOperation = var1;
  153.    }
  154.  
  155.    public void setGlassPane(Component var1) {
  156.       this.getRootPane().setGlassPane(var1);
  157.    }
  158.  
  159.    public void setJMenuBar(JMenuBar var1) {
  160.       this.getRootPane().setMenuBar(var1);
  161.    }
  162.  
  163.    public void setLayeredPane(JLayeredPane var1) {
  164.       this.getRootPane().setLayeredPane(var1);
  165.    }
  166.  
  167.    public void setLayout(LayoutManager var1) {
  168.       if (this.isRootPaneCheckingEnabled()) {
  169.          throw this.createRootPaneException("setLayout");
  170.       } else {
  171.          super.setLayout(var1);
  172.       }
  173.    }
  174.  
  175.    protected void setRootPane(JRootPane var1) {
  176.       if (this.rootPane != null) {
  177.          this.remove(this.rootPane);
  178.       }
  179.  
  180.       this.rootPane = var1;
  181.       if (this.rootPane != null) {
  182.          boolean var2 = this.isRootPaneCheckingEnabled();
  183.  
  184.          try {
  185.             this.setRootPaneCheckingEnabled(false);
  186.             ((Container)this).add(this.rootPane, "Center");
  187.          } finally {
  188.             this.setRootPaneCheckingEnabled(var2);
  189.          }
  190.       }
  191.  
  192.    }
  193.  
  194.    protected void setRootPaneCheckingEnabled(boolean var1) {
  195.       this.rootPaneCheckingEnabled = var1;
  196.    }
  197.  
  198.    public void update(Graphics var1) {
  199.       ((Container)this).paint(var1);
  200.    }
  201. }
  202.